import classnames from 'classnames';
import React from 'react';

interface IRadioProps {
  name?: string;
  checked?: boolean; // 从外部可以控制 是否选中
  value?: string;
  onChange?: () => void;
  disabled?: boolean;
}

export default class Radio extends React.Component<IRadioProps, any> {
  constructor(props: IRadioProps) {
    super(props);
  }

  public render() {
    const {value, name, checked, disabled} = this.props;
    let classString = '';
    const className = 'radio-box';
    if (checked) {
      classString = `radio-checked ${className}`;
    } else if (disabled) {
      classString = `radio-disabled ${className}`;
    } else {
      classString = `${className}`;
    }
    return (
        <label className="radio-wrapper">
          <span className={classString}>
            <input type="radio" {...this.props} className="radio-box-input"/>
            <span className="radio-box-inner"></span>
          </span>
          <span className="radio-name">{name}</span>
        </label>
    );
  }
}
